<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    let arr = [1, 2, 3, 4, 5, 6];
    const res = arr.map(item => {
        return item + 1;
    })
    const result = arr.map((item) => {
        return item * 2
    })
    console.log(res);
    console.log(result[0]);

    // 该方法的第二个参数用来绑定参数函数内部的this变量，是可选的：
    let arr2 = ['a', 'b', 'c','d'];

    const res2 = [0, arr2.length - 1].map(function (e) {
        return this[e];
    }, arr2)
    console.log(res2);

    // 该方法还可以进行链式调用：
    let arr3 = [1, 2, 3];
    const res3 = arr3.map(item => item * 2).map(item => item * 3)
    console.log(res3);
</script>

</html>